_realname=ghdl
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=ci
pkgrel=1
pkgdesc="GHDL: the open-source analyzer, compiler, simulator and (experimental) synthesizer for VHDL (LLVM backend) (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
license=('GPL2+')
url='https://github.com/ghdl'
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-llvm")
depends=(
  "${MINGW_PACKAGE_PREFIX}-gcc-ada"
  "${MINGW_PACKAGE_PREFIX}-llvm"
  "${MINGW_PACKAGE_PREFIX}-zlib"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-clang"
)

build() {
  mkdir "${srcdir}/builddir"
  cd "${srcdir}/builddir"
  export CC=clang
  export CXX=clang++
  ../../../../configure \
    --prefix=${MINGW_PREFIX} \
    --with-llvm-config="llvm-config --link-static" \
    LDFLAGS="-static" \
    --enable-libghdl \
    --enable-synth
  make GNATMAKE="gnatmake -j$(nproc)"
}

package() {
  cd "${srcdir}/builddir"
  mkdir -p "${pkgdir}${MINGW_PREFIX}/lib"
  make DESTDIR="${pkgdir}" install
}
